<?php

/*
 * Created by generator
 *
 */

/**
 * Recupere la liste des enregistrements
 * @param object $db database object
 * @return array of data
 */
if (!function_exists('getAllniveausFromDB')) {
	function getAllniveausFromDB($db) {
		$sql = "SELECT nividniv, nivlbnom from gyaniv order by nivlbnom asc";
		$query = $db->query($sql);

		// recuperer les enregistrements
		$records = array();
		foreach ($query->result_array() as $row) {
			$records[] = $row;
		}
		return $records;
	}
}


/**
 * Insere un nouvel enregistrement
 * @param object $db database object
 * @param string ...
 * @return number identifiant
 */
if (!function_exists('insertNewniveau')) {
	function insertNewniveau($db, $nivlbnom) {
		$data=array( 'nivlbnom'=>$nivlbnom );
		$db->insert('gyaniv',$data);
		return $db->insert_id();
	}
}

/**
 * Mise a jour d'un enregistrement
 */
if (!function_exists('updateniveau')) {
	function updateniveau($db, $nividniv, $nivlbnom) {
		$sql = "update gyaniv set nivlbnom = ? where nividniv=?";
		$query = $db->query($sql, array($nivlbnom, (int)$nividniv ));
	}
}


/**
 * Suppression d'un enregistrement
 */
if (!function_exists('deleteniveau')) {
	function deleteniveau($db, $nividniv) {
		$sql = "delete from gyaniv where nividniv=?";
		$query = $db->query($sql, array((int)$nividniv));
	}
}


/**
 * Recupere les informations d'un enregistrement
 * @param object $db database object
 * @param int id de l'enregistrement
 * @return array
 */
if (!function_exists('getniveauRow')) {
	function getniveauRow($db, $nividniv) {
		$sql = "select nividniv, nivlbnom from gyaniv " .
		"where nividniv=?";
		$query = $db->query($sql, array((int)$nividniv));
		if ($query->num_rows() == 0) {
			return null;
		}
		return $query->row_array();
	}
}

	/***************************************************************************
	 * USER DEFINED FUNCTIONS
	 ***************************************************************************/


?>
